import Vue from 'vue'
import Router from 'vue-router'
const _import = require('./_import_' + process.env.NODE_ENV)
// in development env not use Lazy Loading,because Lazy Loading too many pages will cause webpack hot update too slow.so only in production use Lazy Loading

Vue.use(Router)

/* layout */
import Layout from '../views/layout/Layout'

/**
* icon : the icon show in the sidebar
* hidden : if `hidden:true` will not show in the sidebar
* redirect : if `redirect:noredirect` will no redirct in the levelbar
* noDropdown : if `noDropdown:true` will has no submenu
* meta : { role: ['admin'] }  will control the page role
**/
export const constantRouterMap = [
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: '首页',
    hidden: true,
    children: [{ path: 'dashboard', component: _import('dashboard/index') }]
  },
  {
    path: '/base',
    component: Layout,
    redirect: '/base/instances',
    name: '基础管理',
    icon: 'tubiao',
    children: [
      { path: 'instances', component: _import('base/instances'), name: '实例管理' },
      { path: 'domainAlarm', component: _import('base/domainAlarm'), name: '模块异常告警' },
      { path: 'instancesIpt', component: _import('base/instancesIpt'), name: '实例监控' },
      { path: 'instanceTypes', component: _import('base/instanceTypes'), name: '实例类型', hidden: true },
      { path: 'tags', component: _import('base/tags'), name: '标签管理', hidden: true },
      { path: 'groups', component: _import('base/groups'), name: '应用分组' }
    ]
  },
  {
    path: '/sites',
    component: Layout,
    redirect: '/sites/index',
    name: '云监控',
    icon: 'tubiao',
    children: [
      { path: 'index', component: _import('sites/index'), name: '站点管理 ' },
      { path: 'sitesallRule', component: _import('sites/sitesallRule'), name: '全部规则', hidden: true },
      { path: 'sitesRule/:rid', component: _import('sites/sitesRule'), name: '规则', hidden: true }
    ]
  },
  {
    path: '/alarm',
    component: Layout,
    redirect: '/alarm/index',
    name: '告警服务',
    icon: 'tubiao',
    children: [
      { path: 'index', component: _import('alarm/index'), name: '告警历史' },
      { path: 'templet', component: _import('alarm/templet'), name: '告警模板' },
      { path: 'rules', component: _import('alarm/rules'), name: '告警规则' },
      { path: 'alarmContacts', component: _import('alarm/alarmContacts'), name: '报警联系人' },
      { path: 'alarmContent', component: _import('alarm/alarmContent'), name: '短信告警模板' },
      { path: 'network', component: _import('alarm/network'), name: '网络关键字告警' }
    ]
  },
  {
    path: '/msg',
    component: Layout,
    redirect: '/msg/index/all',
    name: '消息中心',
    icon: 'tubiao',
    children: [
       { path: 'type', component: _import('msg/type'), name: '类型配置' },
       { path: 'receiveConf', component: _import('msg/receiveConf'), name: '基本接收管理' },
       { path: 'index/all', component: _import('msg/index'), name: '全部消息' },
       { path: 'index/no', component: _import('msg/index'), name: '未读消息' },
       { path: 'index/re', component: _import('msg/index'), name: '已读消息' },
       { path: 'alarms', component: _import('msg/alarms'), name: '告警列表' },
       { path: 'details/:rid', component: _import('msg/details'), name: '消息详情', hidden: true }
    ]
  },
  {
    path: '/urlAction',
    component: Layout,
    redirect: '/urlAction/index',
    name: '用户行为收集',
    icon: 'tubiao',
    children: [
      { path: 'index', component: _import('urlAction/index'), name: '埋点上报URL信息' }
    ]
  },
  {
    path: '/business',
    component: Layout,
    redirect: '/business/index',
    name: '流量监控管理',
    icon: 'tubiao',
    children: [
      { path: 'index', component: _import('business/index'), name: '线上平台流量监控' }
    ]
  },
  {
    path: '/urldiagram',
    component: Layout,
    redirect: '/urldiagram/index',
    name: '链路管理',
    icon: 'tubiao',
    children: [
      { path: 'urlconf', component: _import('urldiagram/urlconf'), name: '链路洞察' }
    ]
  },
  {
    path: '/schedule',
    component: Layout,
    redirect: '/schedule/index',
    name: '系统管理',
    icon: 'tubiao',
    children: [
      { path: 'index', component: _import('schedule/index'), name: '定时器管理' },
      { path: 'scheduleLog', component: _import('schedule/schedule_log'), name: '定时器日志', hidden: true }
    ]
  },
  {
    path: '/businessMonitor',
    component: Layout,
    redirect: '/businessMonitor/index',
    name: '业务监控',
    icon: 'tubiao',
    children: [
      { path: 'index', component: _import('businessMonitor/index'), name: '监控图表' },
      { path: 'receiver', component: _import('businessMonitor/receiver'), name: '接收人设置', hidden: true }
    ]
  },
  {
    path: '/faultdrill',
    component: Layout,
    redirect: '/faultdrill/index',
    name: '故障演练',
    children: [
      { path: 'index', component: _import('faultdrill/index'), name: '故障演练' },
      { path: 'shellindex', component: _import('faultdrill/shellindex'), name: '故障演练' }
    ]
  },
  {
    path: '/alarmscreen',
    component: Layout,
    redirect: '/alarmscreen/index',
    name: '大盘服务',
    hidden: true,
    children: [{ path: 'index', component: _import('alarmscreen/index') }]
  },
  {
    path: '/capacity',
    component: Layout,
    redirect: '/capacity/index',
    name: '容量管理',
    children: [
      { path: 'index', component: _import('capacity/index'), name: '容量数据采集' }
    ]
  },
  { path: '/404', component: _import('errorPage/404'), hidden: true },
  { path: '/401', component: _import('errorPage/401'), hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
